import re

string = "7hello wo5rld6  #mobile#,  wefpwf"

# # finditer
# result = re.finditer("hello", string)
# for e in result:
#     print(e)

# 在 string 中通过 hello 的规则搜索目标，符合规则的字符串拿出来
result = re.search('hello', string)
print(result)

result = re.search('wor', string)
print(result)

# search 这个方法只匹配一次，只会返回符合要求的第一个结果。
result = re.search('\d', string)
print(result)


# # finditer
result = re.finditer('\d', string)
for e in result:
    print(e)


result = re.search('\D', string)
print(result)

# result = re.finditer('\D', string)
# for e in result:
#     print(e)

# \W 大写是非字符  ， 字符指的 a-z A-Z 0-9 _
string = "@7hello wo5rld6  #mobile#,  wefpwf"
result = re.search('\W', string)
print(result)

# \s 匹配空格或者 tab
result = re.search('\s', string)
print(result)


# .匹配任意字符
result = re.search('.', string)
print(result)


# .匹配任意字符
result = re.search('.?', string)
print(result)

# *匹配前一个字符0次或者任意次
result = re.search('.*', string)
print(result)

# string = "1212@7hello wo5rld6  #mobile#,  wefpwf"
# result = re.search('h*', string)
# print(result)

